package com.bodu.exchange.client.impl;

import com.bodu.core.entity.ParamReq;
import com.bodu.core.entity.enums.DelFlagEnum;
import com.bodu.core.entity.result.Result;
import com.bodu.exchange.client.ExchangeBillClient;
import com.bodu.exchange.entity.request.ExchangeBillRequest;
import com.bodu.exchange.entity.vo.ExchangeBillTypeVo;
import com.bodu.exchange.entity.vo.ExchangeBillVo;
import com.bodu.exchange.service.ExchangeBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 */
@Service
public class ExchangeBillClientImpl implements ExchangeBillClient {
    
    @Autowired
    private ExchangeBillService exchangeBillService;
    
    @Override
    public Result<Long> createBill(ExchangeBillRequest exchangeBillTypeRequest) {
        Long billCount = exchangeBillService.save(exchangeBillTypeRequest);
        return Result.success(billCount);
    }

    @Override
    public Result<Long> deleteBill(Long id) {
        Integer count = exchangeBillService.updateDelFlagById(id, DelFlagEnum.NO.getValue());
        return Result.success(count);
    }

    @Override
    public Result<ExchangeBillVo> billList(ParamReq<ExchangeBillRequest> request) {
        List<ExchangeBillVo> list = exchangeBillService.listPage(request);
        
        return Result.success(list);
    }
}
